﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button1_Click(object sender, EventArgs e)
    {

    }

    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (Session["user_id"] != null) {
            order order = new order();

            for (int i = 1; i < 10; i++) {
                System.Diagnostics.Debug.Write(this.GridView1.SelectedRow.Cells[i].Text);
            }

            order.id = Convert.ToInt32(this.GridView1.SelectedRow.Cells[1].Text);
            order.fly_name = this.GridView1.SelectedRow.Cells[2].Text;
            order.type = this.GridView1.SelectedRow.Cells[3].Text;



            order.takeoff_time = DateTime.ParseExact(GridView1.SelectedRow.Cells[4].Text, "yyyy/MM/dd", System.Globalization.CultureInfo.InvariantCulture);


            order.land_time = DateTime.ParseExact(GridView1.SelectedRow.Cells[5].Text, "yyyy/MM/dd", System.Globalization.CultureInfo.InvariantCulture);

            order.start_place = this.GridView1.SelectedRow.Cells[6].Text;
            order.end_place = this.GridView1.SelectedRow.Cells[7].Text;


            order.num = Convert.ToInt32(this.GridView1.SelectedRow.Cells[8].Text);
            order.price = Convert.ToSingle(this.GridView1.SelectedRow.Cells[9].Text);

            //System.Diagnostics.Debug.Write(order.id+ order.fly_name+ order.type+ order.takeoff_time+ order.land_time+order.start_place+ order.end_place+ order.num+ order.price);

            //order.name = this.GridView1.SelectedRow.Cells[1].Text;

            //order.idcard = this.GridView1.SelectedRow.Cells[1].Text;

            //order.paystatus = this.GridView1.SelectedRow.Cells[1].Text;

            order.name = Session["user_name"].ToString();

            order.idcard = Session["user_idcard"].ToString();

            order.paystatus = "未付款";

            order order1 = new order();
            order1.insertOrder(order);
            Response.AddHeader("Refresh", "0");
            Response.Write("<script>alert('订票成功')</script>");
        }
        else {

            Response.Write("<script>alert('请先登录')</script>");
        }
    }

    protected void FormView1_PageIndexChanging(object sender, FormViewPageEventArgs e)
    {

    }
}